//
//  SPMusicPreferencesViewController.m
//  Sophie
//
//  Created by Anton Chebotaev on 25/10/09.
//  Copyright 2009 IFMO. All rights reserved.
//

#import "SPMusicPreferencesViewController.h"

@interface SPMusicPreferencesViewController (Callbacks) 
@end

@implementation SPMusicPreferencesViewController

#pragma mark Lifecycle
- (id)init {
	self = [super initWithNibName:@"MusicPreferencesTab" bundle:nil];
	return self;
}

- (void)dealloc {
	[super dealloc];
}

#pragma mark Required by MBPreferencesModule
- (NSString *)title {
	return NSLocalizedString(@"Music", @"Title of 'Music' preference pane");
}
- (NSString *)identifier {
	return @"Music Preferences";
}
- (NSImage *)image {
	return [NSImage imageNamed:@"iTunes"];
}

#pragma mark Optional by MBPreferencesModule
- (void)willBeDisplayed {
	
	
	
	[avaiableTokensField setObjectValue:[NSArray arrayWithObjects:
										 [SPMusicFormatToken titleToken],
										 [SPMusicFormatToken albumToken],
										 [SPMusicFormatToken artistToken],
										 [SPMusicFormatToken genreToken],
										 [SPMusicFormatToken ratingToken],
										 nil]];
	
	[musicFormatField setObjectValue:[[SPPreferencesController sharedController] musicFormat]];
	[musicFormatField setTokenizingCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@""]];
}

#pragma mark IBActions
- (IBAction)saveMusicFormat:(id)sender {
	[[SPPreferencesController sharedController] setMusicFormat:[musicFormatField objectValue]];	
	
	NSString *currentMusic = [SPAppDelegate getCurrentMusicString];
	if ([currentMusic isEqual:@""]) {
		[testTextFeild setStringValue:@"Nothinng is played bu iTunes right now"];
	}
	else {
		[testTextFeild setStringValue:currentMusic];
	}
}

@end
